
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <title>02-案例1：自制老虎机 · GitBook</title>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.0.0">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="03-案例2：抽奖小游戏.html" />
    
    
    <link rel="prev" href="01-课程介绍.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="01-课程介绍.html">
            
                <a href="01-课程介绍.html">
            
                    
                    01-课程介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3" data-path="02-案例1：自制老虎机.html">
            
                <a href="02-案例1：自制老虎机.html">
            
                    
                    02-案例1：自制老虎机
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="03-案例2：抽奖小游戏.html">
            
                <a href="03-案例2：抽奖小游戏.html">
            
                    
                    03-案例2：抽奖小游戏
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="04-案例3：借用系统.html">
            
                <a href="04-案例3：借用系统.html">
            
                    
                    04-案例3：投影仪借用系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="05-案例4：统计评价结果.html">
            
                <a href="05-案例4：统计评价结果.html">
            
                    
                    05-案例4：统计评价结果
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >02-案例1：自制老虎机</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x81EA;&#x5236;&#x8001;&#x864E;&#x673A;">&#x81EA;&#x5236;&#x8001;&#x864E;&#x673A;</h1>
<h3 id="1-&#x8001;&#x864E;&#x673A;&#x6E38;&#x620F;&#x89C4;&#x5219;&#x4ECB;&#x7ECD;">1. &#x8001;&#x864E;&#x673A;&#x6E38;&#x620F;&#x89C4;&#x5219;&#x4ECB;&#x7ECD;</h3>
<p>&#x8001;&#x864E;&#x673A;&#xFF08;slot machine&#xFF09; &#x662F;&#x4E00;&#x79CD;&#x7528;&#x96F6;&#x94B1;&#x8D4C;&#x535A;&#x7684;&#x673A;&#x5668;&#xFF0C;&#x56E0;&#x4E3A;&#x4E0A;&#x9762;&#x6709;&#x8001;&#x864E;&#x56FE;&#x6848;&#x7684;&#x7B79;&#x7801;&#x800C;&#x5F97;&#x540D;&#x3002;&#x8001;&#x864E;&#x673A;&#x6709;&#x4E09;&#x4E2A;&#x73BB;&#x7483;&#x6846;&#xFF0C;&#x91CC;&#x9762;&#x6709;&#x4E0D;&#x540C;&#x7684;&#x56FE;&#x6848;&#xFF0C;&#x6295;&#x5E01;&#x4E4B;&#x540E;&#x62C9;&#x4E0B;&#x62C9;&#x6746;&#xFF0C;&#x5C31;&#x4F1A;&#x5F00;&#x59CB;&#x8F6C;&#xFF0C;&#x5982;&#x679C;&#x51FA;&#x73B0;&#x7279;&#x5B9A;&#x7684;&#x56FE;&#x5F62;&#xFF08;&#x6BD4;&#x5982;&#x4E09;&#x4E2A;&#x76F8;&#x540C;&#xFF09;&#x5C31;&#x4F1A;&#x5410;&#x94B1;&#x51FA;&#x6765;&#xFF0C;&#x51FA;&#x73B0;&#x76F8;&#x540C;&#x56FE;&#x578B;&#x8D8A;&#x591A;&#x5956;&#x91D1;&#x5219;&#x8D8A;&#x9AD8;&#x3002;</p>
<font color="red">**&#x53CB;&#x60C5;&#x63D0;&#x793A;&#xFF1A;&#x4E25;&#x7981;&#x8D4C;&#x535A;&#xFF0C;&#x5341;&#x8D4C;&#x5341;&#x8F93;&#x3002;**</font>



<h3 id="2-&#x6848;&#x4F8B;&#x9700;&#x6C42;">2. &#x6848;&#x4F8B;&#x9700;&#x6C42;</h3>
<ol>
<li><p>&#x968F;&#x673A;&#x4ECE; &#x5B57;&#x7B26;&#x4E32; <code>&apos;7&#x266A;&#x266B;&#x2663;&#x2660;&#x2666;&#x2665;&#x25C4;&#x263C;&#x263D;&apos;</code> &#x4E2D;&#x83B7;&#x53D6;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#xFF0C;&#x7EC4;&#x6210;&#x4E00;&#x7EC4;&#x4E09;&#x4E2A;&#x7B26;&#x53F7;&#x7684;&#x7ED3;&#x679C;</p>
</li>
<li><p>&#x7ED3;&#x679C;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python">&#x263D; | &#x263C; | &#x2666;

&#x263C; | <span class="hljs-number">7</span> | &#x25C4;

<span class="hljs-number">7</span> | &#x2666; | <span class="hljs-number">7</span>

&#x263D; | &#x263D; | &#x266B;

<span class="hljs-number">7</span> | <span class="hljs-number">7</span> | &#x2663;

&#x263D; | &#x25C4; | &#x263C;

&#x2665; | &#x263D; | &#x2663;
</code></pre>
</li>
<li><p>&#x53EF;&#x4EE5;&#x505A;&#x4E00;&#x4E2A;20&#x6B21;&#x7684;&#x6709;&#x9650;&#x6B21;&#x5FAA;&#x73AF;&#x6765;&#x5B8C;&#x6210;&#x6B64;&#x6848;&#x4F8B;</p>
</li>
</ol>
<h3 id="3-&#x6848;&#x4F8B;&#x63D0;&#x793A;">3. &#x6848;&#x4F8B;&#x63D0;&#x793A;</h3>
<ul>
<li>&#x901A;&#x8FC7;random&#x6A21;&#x5757;&#x5B9E;&#x73B0;&#x968F;&#x673A;&#x9009;&#x62E9;&#x3002;<ul>
<li>random.randint()</li>
<li>random.randrange()</li>
<li>random.choice()</li>
<li>random.choices()</li>
</ul>
</li>
<li>&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x683C;&#x5F0F;&#x5316;&#x8F93;&#x51FA;<ul>
<li>format()&#x51FD;&#x6570;</li>
<li>%&#x683C;&#x5F0F;&#x5316;</li>
<li>f&#x5B57;&#x7B26;&#x4E32;</li>
</ul>
</li>
</ul>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="01-课程介绍.html" class="navigation navigation-prev " aria-label="Previous page: 01-课程介绍">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="03-案例2：抽奖小游戏.html" class="navigation navigation-next " aria-label="Next page: 03-案例2：抽奖小游戏">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"02-案例1：自制老虎机","level":"1.3","depth":1,"next":{"title":"03-案例2：抽奖小游戏","level":"1.4","depth":1,"path":"03-案例2：抽奖小游戏.md","ref":"03-案例2：抽奖小游戏.md","articles":[]},"previous":{"title":"01-课程介绍","level":"1.2","depth":1,"path":"01-课程介绍.md","ref":"01-课程介绍.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"02-案例1：自制老虎机.md","mtime":"2021-11-24T09:11:35.371Z","type":"markdown"},"gitbook":{"version":"3.0.0","time":"2021-11-25T03:30:03.989Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/buttons.js"></script>
        
    

    </body>
</html>

